﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZBJF.Warranty.Common.Common;
using ZBJF.Warranty.Common.Enums.Certificate;
using ZBJF.Warranty.TheThirdPartyInteraction.InsuranceCompany.HuaAn.Model;
using ZBJF.Warranty.TheThirdPartyInteraction.InsuranceCompany.HuaAn.Model.Request;
using ZBJF.Warranty.TheThirdPartyInteraction.InsuranceCompany.HuaAn.Model.Response;

namespace ZBJF.Warranty.TheThirdPartyInteraction.InsuranceCompany.HuaAn
{
    public class HuaAnHelper
    {
        #region 尺度项目查询保单信息 + HuaAnInsuranceOrderInfo QueryInsuranceOrderInfo (string chiDuBusinessNo,string huaAnPolicyNo)
        /// <summary>
        /// 尺度项目查询保单信息
        /// </summary>
        /// <param name="chiDuBusinessNo">尺度订单号</param>
        /// <param name="huaAnPolicyNo">华安保单号</param>
        /// <returns></returns>
        public static HuaAnBaseModel<HuaAnInsuranceOrderInfo> QueryInsuranceOrderInfo (string chiDuBusinessNo,string huaAnPolicyNo)
        {
            QueryInsuranceOrderParam param = new QueryInsuranceOrderParam()
            {
                businessNo = chiDuBusinessNo,
                policyNo = huaAnPolicyNo
            };
            WebUtils web = new WebUtils();
            HuaAnBaseModel<HuaAnInsuranceOrderInfo> result = web.DoPost<HuaAnBaseModel<HuaAnInsuranceOrderInfo>>(HuaAnConfig.ChiDuOrderQuery_Test, JsonConvert.SerializeObject(param));
            if (result == null)
                return null;
            return result;
        }
        #endregion

        #region 转换华安的证件类型成本地的
        public static byte ConvertCertificateType(string huaAnCertificateType) {
         // 01  身份证
        /// 02	护照
        /// 03	军人证
        /// 04	学生证
        /// 05	台胞证
        /// 06	港澳返乡证
        /// 07	出生证
        /// 08	出生日期（未成年人使用）
        /// 09	统一社会信用代码
        /// 10	组织机构代码
        /// 11	工商注册号
        /// 12	税务登记号
        /// 13	纳税人识别号
        /// 99	其他
            switch (huaAnCertificateType)
            {
                case "01":
                    return (byte)UserCertificateType.IdentityCard;
                case "02":
                    return (byte)UserCertificateType.Passport;
                case "03":
                    return (byte)UserCertificateType.CertificateOfOfficers;
                case "05":
                    return (byte)UserCertificateType.HKAndMacaoHomeCardOrTaiwanCard;
                case "06":
                    return (byte)UserCertificateType.HKAndMacaoHomeCardOrTaiwanCard;
                default:
                    return (byte)UserCertificateType.OtherCard;
            }
        }
        #endregion

    }
}
